Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api for awaiting responses to gateway send events #591

Merged
merged 4 commits into from
Jan 5, 2025

Conversation

kozabrada123
Copy link
Member

Adds some new methods to GatewayHandle:

  • identify, which functions like send_identify, but waits to receive the response
  • resume, which functions like send_resume, but waits to receive the response
  • request_guild_members, which functions like send_request_guild_members, but waits to receive all GuildMembersChunks
  • update_voice_state, which functions like send_update_voice_state, but waits up to 1 second to receive a potential response
  • request_last_messages, which functions like send_request_last_messages, but waits to receive the response

These work by creating a temporary observer, which sends the event through either a tokio::sync::broadcast or tokio::sync::oneshot channel. These two observer types are now also part of the public api as BroadcastEventObserver<T> and OneshotEventObserver<T>

It also adds Events.session.resumed and GatewayResumed for the Resumed dispatch event. I'm still not sure if resuming is practically possible, since you need to provide the last received sequence number

@kozabrada123 kozabrada123 added Type: Enhancement Enhances an existing feature or behaviour. Type: New feature Module: Gateway labels Dec 30, 2024
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@kozabrada123 kozabrada123 added this to the 0.19.0 milestone Dec 30, 2024
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
src/gateway/handle.rs Fixed Show fixed Hide fixed
@kozabrada123 kozabrada123 marked this pull request as ready for review January 5, 2025 06:55
@kozabrada123 kozabrada123 merged commit 5d4dc2c into dev Jan 5, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Gateway Type: Enhancement Enhances an existing feature or behaviour. Type: New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant